package com.example.prom.ok.y2023.work.au10tix;


import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import com.alibaba.fastjson.JSON;
import com.example.prom.utils.HttpClientSingleton;
import com.example.prom.utils.HttpNewUtils;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.List;

public class Test {
    static {
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        List<Logger> loggerList = loggerContext.getLoggerList();
        loggerList.forEach(logger -> {logger.setLevel(Level.INFO);});
    }
    public static void main(String[] args) throws IOException {
//        String fileUrl = "https://mediasapreus.blob.core.windows.net/ms-617/93B334EE6E7A4279B105A4CDC8D205AD/cdr/93B334EE6E7A4279B105A4CDC8D205AD_page1.jpeg?sv=2021-06-08&spr=https&st=2023-04-18T03%3A57%3A17Z&se=2023-04-18T04%3A08%3A17Z&sr=b&sp=r&sig=BO1w3VRHu5zSA2SKtlNh%2B4tib7IUVHwMAZih6JhWgxc%3D";
//        for (int i = 0; i < 1000; i++) {
//            InputStream inputStream = HttpNewUtils.downLoad4Stream(fileUrl, HttpClientSingleton.getFaceHttpClient(), null);
//            System.out.println(inputStream.available());
//        }

        String licenseKey = "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";
        String fileUrl = "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=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&suffix=tar.gz";
//        String fileUrl = "https://download.maxmind.com/app/geoip_download?edition_id=GeoIP2-City-CSV&license_key="+licenseKey+"&suffix=zip";
        HttpResponse httpResponse = HttpNewUtils.downLoad(fileUrl, HttpClientSingleton.getLongCustomHttpClient(), null);
        System.out.println(JSON.toJSONString(httpResponse));
//        int statusCode = httpResponse.getStatusLine().getStatusCode();
//        String responseBody = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
//        Header[] allHeaders = httpResponse.getAllHeaders();
//        Header[] headers = httpResponse.getHeaders("Last-Modified");
//        for (Header allHeader : allHeaders) {
//            String name = allHeader.getName();
//            if (name.equalsIgnoreCase("Last-Modified")) {
//                String value = allHeader.getValue();
//                System.out.println(value);
//
//            }
//        }
//        System.out.println(JSON.toJSONString(allHeaders));


//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        String format = simpleDateFormat.format("Mon, 17 Apr 2023 15:30:42 GMT");
//        System.out.println(format);

    }
}